#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;

void buildVector(std::vector<int> &v)
{
    srand(time(NULL));
    for (int i = 1; i <= 1000; ++i)
    {
        v.push_back(rand() % 1000 + 1);
    }
}

int searchVector(std::vector<int> v, int value)
{
    /*for (int i = 0; i < v.size(); ++i)
    {
        if (v[i] == value)
        {
            return i;
        }
    }
    return -1;*/
    int found = -1;
    found = v.at(value);
    return found;
}

int main()
{
    std::vector<int> v;
    buildVector(v);
    int found, item;
    cout << "Enter a value to search for: ";
    cin >> item;
    found = searchVector(v, item);
    if (found > -1)
    {
        cout << "Found the item at position: "
             << found << endl;
    }
    else
        cout << "Did not find the item..."
             << endl;

    return 0;
}
